package com.speily.cloud.consumer.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Auther: SPL
 * @Date: 2019-06-20 13:36
 * @Description: 远程调用service
 */
@FeignClient(name= "cloud-api-a",fallback = HelloRemote.HystrixHelloRemote.class)  //name:远程服务名，及spring.application.name配置的名称
public interface HelloRemote {
    @RequestMapping(value = "/a/hello")
    String hello(@RequestParam(value = "name") String name);

    /**
     *  HelloRemote 的 熔断器
     */
    @Component
    class HystrixHelloRemote implements HelloRemote{

        @Override
        public String hello(@RequestParam(value = "name") String name) {
            return "Hystrix:" + name +", 服务调用失败 ";
        }
    }
}
